n = [1,7,5,4,3,8]
s = 4
for i in range(s):
    removed = False
    for j in range(len(n) - 1):
       if n[j] > n[j + 1]:
           del n[j]
           removed = True
           break

    if removed == False:
        n.pop()

print(n)